import java.util.Scanner;

public class Main1815 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long [] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i]=sc.nextLong();
        }
        int number = sc.nextInt();
        for(int i=n-1;i>1;i--){
            if(number==a[i]){
                System.out.print(i+1);
                return;
            }
        }
        System.out.print("-1");
    }
}
